package com.itheima.job2;

import java.io.File;

public class Test {
    public static void main(String[] args){
        File file = new File("E:test");
        removeFile(file);
    }

    public static void removeFile(File dir){
        if (!dir.exists()||dir.isFile()||dir==null){
            return;
        }
        File[] files = dir.listFiles();

        if (files!=null&&files.length!=0){
            for (int i = 0; i < files.length; i++) {
                if (files[i].isFile()){
                    files[i].delete();
                }else {
                    removeFile(files[i]);
                }
            }
            dir.delete();
        }


    }
}
